<template>
  <el-row :gutter="16" class="dashboard-console-grid">
    <!-- 用户管理 -->
    <el-col v-bind="grid" class="mb-4">
      <el-card shadow="never">
        <router-link :to="{ path: '/user/list' }" class="card-link">
          <div class="icon">
            <i class="iconfont iconyonghuguanli" style="color: #0256ff"></i>
          </div>
          <p>用户管理</p>
        </router-link>
      </el-card>
    </el-col>

    <!-- 系统设置 -->
    <el-col v-bind="grid" class="mb-4" v-auth="['setting-system-config']">
      <el-card shadow="never">
        <router-link :to="{ path: '/setting/system_config' }" class="card-link">
          <div class="icon">
            <i class="iconfont iconxitongshezhi" style="color: #9fdb1d"></i>
          </div>
          <p>系统设置</p>
        </router-link>
      </el-card>
    </el-col>

    <!-- 商品管理 -->
    <el-col v-bind="grid" class="mb-4" v-auth="['admin-store-storeProuduct-index']">
      <el-card shadow="never">
        <router-link :to="{ path: '/product/product_list' }" class="card-link">
          <div class="icon">
            <i class="iconfont iconshangpin" style="color: #0fc6c2"></i>
          </div>
          <p>商品</p>
        </router-link>
      </el-card>
    </el-col>

    <!-- 订单管理 -->
    <el-col v-bind="grid" class="mb-4" v-auth="['admin-order-storeOrder-index']">
      <el-card shadow="never">
        <router-link :to="{ path: '/order/list' }" class="card-link">
          <div class="icon">
            <i class="iconfont icondingdanguanli" style="color: #b37feb"></i>
          </div>
          <p>订单管理</p>
        </router-link>
      </el-card>
    </el-col>

    <!-- 短信配置 -->
    <el-col v-bind="grid" class="mb-4" v-auth="['setting-sms']">
      <el-card shadow="never">
        <router-link :to="{ path: '/setting/sms/sms_config/index' }" class="card-link">
          <div class="icon">
            <i class="iconfont iconduanxinpeizhi" style="color: #f7ba1e"></i>
          </div>
          <p>短信配置</p>
        </router-link>
      </el-card>
    </el-col>

    <!-- 文章管理 -->
    <el-col v-bind="grid" class="mb-4" v-auth="['cms-article-index']">
      <el-card shadow="never">
        <router-link :to="{ path: '/cms/article/index' }" class="card-link">
          <div class="icon">
            <i class="iconfont iconwenzhangguanli" style="color: #7da2ff"></i>
          </div>
          <p>文章管理</p>
        </router-link>
      </el-card>
    </el-col>

    <!-- 分销管理 -->
    <el-col v-bind="grid" class="mb-4" v-auth="['agent-agent-manage']">
      <el-card shadow="never">
        <router-link :to="{ path: '/agent/agent_manage/index' }" class="card-link">
          <div class="icon">
            <i class="iconfont iconfenxiaoguanli" style="color: #ff7d00"></i>
          </div>
          <p>分销管理</p>
        </router-link>
      </el-card>
    </el-col>

    <!-- 优惠券 -->
    <el-col v-bind="grid" class="mb-4" v-auth="['marketing-store_coupon-index']">
      <el-card shadow="never">
        <router-link :to="{ path: '/marketing/store_coupon_issue/index' }" class="card-link">
          <div class="icon">
            <i class="iconfont iconyouhuiquan4" style="color: #0fc6c2"></i>
          </div>
          <p>优惠券</p>
        </router-link>
      </el-card>
    </el-col>
  </el-row>
</template>

<script setup>
import { ref } from 'vue';

// 响应式网格配置
const grid = ref({
  xl: 3,
  lg: 3,
  md: 6,
  sm: 6,
  xs: 12,
});
</script>

<style lang="scss" scoped>
.dashboard-console-grid {
  text-align: center;

  // 卡片内边距重置（Element Plus 使用 .el-card__body）
  .el-card__body {
    padding: 0;
  }

  // 图标容器样式
  .icon {
    width: 48px;
    height: 48px;
    background-color: #f6f6f6;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto; // 水平居中
  }

  // 图标样式
  .iconfont {
    font-size: 24px;
  }

  // 链接样式（统一替换 ivu-card-body 的 padding）
  .card-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: inherit;
    padding: 16px;
    text-decoration: none; // 去除下划线

    //  hover 效果优化
    &:hover {
      .icon {
        background-color: #eee;
      }

      p {
        color: #0256ff;
      }
    }
  }

  // 文字样式
  p {
    margin-top: 8px;
    font-size: 14px;
    font-weight: 400;
    color: #333333;
    line-height: 22px;
    white-space: nowrap;
  }
}
</style>